package com.hucheng.activity.vo;

import com.hucheng.activity.entity.LuckPrizeDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-10
 * @Description: 返回界面数据
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LuckPrizeVO implements Serializable {
    private Integer luckPrizeConfigId;
    private String luckPrizeConfigName;
    private Integer status;
    private Integer freeCount;
    private String dateStart;
    private String dateEnd;
    private Integer point;
    private Integer limitCount;
    private String luckPrizeRemark;
    private Integer isDel;
    private String dateCreated;
    private String dateUpdated;

    public static LuckPrizeVO buildLuckPrizeVO(final LuckPrizeDO luckPrizeDO) {
        if (luckPrizeDO == null) {
            return null;
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new LuckPrizeVO(
                luckPrizeDO.getLuckPrizeConfigId(),
                luckPrizeDO.getLuckPrizeConfigName(),
                luckPrizeDO.getStatus(),
                luckPrizeDO.getFreeCount(),
                sdf.format(luckPrizeDO.getDateStart()),
                sdf.format(luckPrizeDO.getDateEnd()),
                luckPrizeDO.getPoint(),
                luckPrizeDO.getLimitCount(),
                luckPrizeDO.getLuckPrizeRemark(),
                luckPrizeDO.getIsDel(),
                dateTimeFormatter.format(luckPrizeDO.getDateCreated().toLocalDateTime()),
                dateTimeFormatter.format(luckPrizeDO.getDateUpdated().toLocalDateTime()));
    }
}
